package com.zhousb.deviceManager.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhousb.deviceManager.common.PageRequest;
import com.zhousb.deviceManager.common.R;
import com.zhousb.deviceManager.common.ResponseResult;
import com.zhousb.deviceManager.model.so.AssetEpcRelationSo;
import com.zhousb.deviceManager.model.so.AssetSo;
import com.zhousb.deviceManager.service.AssetEpcRelationService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/relation")
public class AssetEpcRelationController {

    @Resource
    private AssetEpcRelationService assetEpcRelationService;
    @PostMapping("/page")
    public ResponseResult page(@RequestBody PageRequest<AssetEpcRelationSo> so) {
        return R.success(assetEpcRelationService.page(new Page<>(so.getCurrent(),so.getSize()),so.getQuery() ));
    }

    @GetMapping("/delete")
    public ResponseResult delete(@RequestParam("code")String code) {
        return R.success(assetEpcRelationService.delete(code));
    }

    @PostMapping("/import")
    public ResponseResult importExcel(@RequestParam("file") MultipartFile file) throws IOException {
        return R.success(assetEpcRelationService.importExcel(file));
    }
}
